{include file="common/pc/header" title="新增自定义设置" /}

<style>
    body {
        padding: 10px;
    }
</style>

<form class="layui-form" action="" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">模块</label>
        <div class="layui-input-block">
            {php}
            $val = fetch($tpl, 'module', '*');
            {/php}
            <input type="text" name="module" required lay-verify="required" placeholder="请输入模块"
                   class="layui-input" value="{$val}"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">控制器</label>
        <div class="layui-input-block">
            {php}
            $val = fetch($tpl, 'controller', '*');
            {/php}
            <input type="text" name="controller" required lay-verify="required" placeholder="请输入控制器"
                   class="layui-input" value="{$val}"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">页面</label>
        <div class="layui-input-block">
            {php}
            $val = fetch($tpl, 'action', '*');
            {/php}
            <input type="text" name="action" required lay-verify="required" placeholder="请输入页面"
                   class="layui-input" value="{$val}"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">语言环境</label>
        <div class="layui-input-block">
            {php}
            $val = fetch($tpl, 'langset', '*');
            {/php}
            <input type="text" name="langset" required lay-verify="required" placeholder="请输入语言环境"
                   class="layui-input" value="{$val}"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">代码名称</label>
        <div class="layui-input-block">
            {php}
            $val = fetch($tpl, 'name', '');
            {/php}
            <input type="text" name="name" required lay-verify="required" placeholder="请输入代码名称"
                   class="layui-input" value="{$val}"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">类型</label>
        <div class="layui-input-block">
            <select name="type" required lay-verify="required">
                {foreach name="types" item="typeTitle" key="typeCode"}
                <option value="{$typeCode}">{$typeTitle}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="add">创建</button>
        </div>
    </div>
</form>

<script>
    layui.use('form', function () {
        var form = layui.form;

        form.on("submit(add)", function (data) {
            $.post("add", data.field, function (response) {
                if (response.code == 1) {
                    document.location.href = "edit?id=" + response.data.key;
                } else {
                    layer.alert(response.msg);
                }
            }, "json");
            return false;
        });
    });
</script>

{include file="common/pc/footer"/}